package com.wandousoushu.jiusen.help

import com.wandousoushu.jiusen.MyApplication
import com.wandousoushu.jiusen.R
import com.wandousoushu.jiusen.util.getPrefBoolean
import com.wandousoushu.jiusen.util.getPrefInt
import com.wandousoushu.jiusen.util.putPrefBoolean
import com.wandousoushu.jiusen.util.putPrefInt

object ReadTipConfig {
    val tipArray: Array<String> = MyApplication.appResources.getStringArray(R.array.read_tip)
    const val none = 0
    const val chapterTitle = 1
    const val time = 2
    const val battery = 3
    const val page = 4
    const val totalProgress = 5
    const val pageAndTotal = 6

    val tipHeaderLeftStr: String get() = tipArray.getOrElse(tipHeaderLeft) { tipArray[none] }
    val tipHeaderMiddleStr: String get() = tipArray.getOrElse(tipHeaderMiddle) { tipArray[none] }
    val tipHeaderRightStr: String get() = tipArray.getOrElse(tipHeaderRight) { tipArray[none] }
    val tipFooterLeftStr: String get() = tipArray.getOrElse(tipFooterLeft) { tipArray[none] }
    val tipFooterMiddleStr: String get() = tipArray.getOrElse(tipFooterMiddle) { tipArray[none] }
    val tipFooterRightStr: String get() = tipArray.getOrElse(tipFooterRight) { tipArray[none] }

    var tipHeaderLeft: Int
        get() = MyApplication.instance.getPrefInt("tipHeaderLeft", time)
        set(value) {
            MyApplication.instance.putPrefInt("tipHeaderLeft", value)
        }

    var tipHeaderMiddle: Int
        get() = MyApplication.instance.getPrefInt("tipHeaderMiddle", none)
        set(value) {
            MyApplication.instance.putPrefInt("tipHeaderMiddle", value)
        }

    var tipHeaderRight: Int
        get() = MyApplication.instance.getPrefInt("tipHeaderRight", battery)
        set(value) {
            MyApplication.instance.putPrefInt("tipHeaderRight", value)
        }

    var tipFooterLeft: Int
        get() = MyApplication.instance.getPrefInt("tipFooterLeft", chapterTitle)
        set(value) {
            MyApplication.instance.putPrefInt("tipFooterLeft", value)
        }

    var tipFooterMiddle: Int
        get() = MyApplication.instance.getPrefInt("tipFooterMiddle", none)
        set(value) {
            MyApplication.instance.putPrefInt("tipFooterMiddle", value)
        }

    var tipFooterRight: Int
        get() = MyApplication.instance.getPrefInt("tipFooterRight", pageAndTotal)
        set(value) {
            MyApplication.instance.putPrefInt("tipFooterRight", value)
        }

    var hideHeader: Boolean
        get() = MyApplication.instance.getPrefBoolean("hideHeader", true)
        set(value) {
            MyApplication.instance.putPrefBoolean("hideHeader", value)
        }

    var hideFooter: Boolean
        get() = MyApplication.instance.getPrefBoolean("hideFooter", false)
        set(value) {
            MyApplication.instance.putPrefBoolean("hideFooter", value)
        }
}